package com.open.basic.constant;

/**
 * @author: system
 * @Date: 2024/4/11 23:39
 * @Version: V1.0
 * @description: desc:表示业务操作成功与否的编码和信息
 */

public enum BizConstant {

    BIZ_SUCCESS("bizSuccess", "业务操作成功"),

    BIZ_FAILURE("bizFailure", "业务操作失败"),

    BIZ_EXCEPTION("bizException", "业务异常"),

    DATA_INVALID("dataInvalid", "数据校验失败"),

    DATA_NOT_EXIST("dataNotExist", "数据不存在"),

    DATA_MISSED("dataMissed", "必填参数缺失"),

    NUMBER_INVALID("numberInvalid", "无效的数字"),

    EMAIL_INVALID("emailInvalid", "无效的邮箱"),

    DATE_INVALID("dateInvalid", "无效的日期"),

    PHONE_INVALID("phoneInvalid", "无效的电话号码"),

    SYSTEM_EXCEPTION("systemException", "系统异常");


    /**
     * 业务操作结果编码
     */
    final String code;

    /**
     * 业务操作结果信息
     */
    final String message;

    BizConstant(java.lang.String code, java.lang.String message) {
        this.code = code;
        this.message = message;
    }

    public static BizConstant getByCode(String code) {
        for (BizConstant bizConstant : values()) {
            if (bizConstant.code.equals(code)) {
                return bizConstant;
            }
        }
        return null;
    }
    
    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }
}

